package com.macro.mall.portal.component;

import com.macro.mall.model.OmsDistributionOrder;
import com.macro.mall.portal.service.OmsDistributionOrderService;
import com.macro.mall.portal.service.OmsDistributionStoreOrderService;
import com.macro.mall.portal.service.OmsPortalOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * 创建分销订单消费者
 * @author zhouboyu
 * @Date 2020年9月1日
 *
 */
@Component
@RabbitListener(queues = "mall.distribution.creat")
public class DistributionCreatReceiver {
    private static Logger LOGGER =LoggerFactory.getLogger(DistributionCreatReceiver.class);
    @Autowired
    private OmsDistributionOrderService omsDistributionOrderService;
    @Autowired
    private OmsDistributionStoreOrderService omsDistributionStoreOrderService;
    @RabbitHandler
    public void handle(Long orderId){
        System.out.println("创建提现那两个表的方法");
        try {
            this.omsDistributionOrderService.insertByOrderId(orderId);
            this.omsDistributionStoreOrderService.insertByOrderId(orderId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        LOGGER.info("process orderId:{}",orderId);
        LOGGER.info("创建分销订单会尽快国际化国际化---------------mq",orderId);
    }
}
